function setOnShowScene(e) {
  getApp().onShowData || (getApp().onShowData = {}), getApp().onShowData.scene = e;
}

Page({
  data: {
      selected: -1,
      tpl_msg_id: ''
  },
  log:function(){
    wx.navigateTo({
      url: '/mch/m/mch-live-package-log/mch-live-package-log',
    })
  },
  onLoad: function(e) {
      getApp().page.onLoad(this, e);
      if (this.data.store.is_shenhe == 0) {
        wx.setNavigationBarTitle({
          title: '充值'
        })
      }
      var n = this;
      getApp().core.showLoading({
          title: "加载中"
      }), getApp().request({
          url: getApp().api.mch.user.get_live_package,
          success: function(e) {
             
              n.setData(e.data);
          },
          complete: function(e) {
              getApp().core.hideLoading();
          }
      });
  },
  onReady: function() {
      getApp().page.onReady(this);
  },
  onShow: function() {
      getApp().page.onShow(this);
  },
  onHide: function() {
      getApp().page.onHide(this);
  },
  onUnload: function() {
      getApp().page.onUnload(this);
  },
  click: function(e) {
      this.setData({
          selected: e.currentTarget.dataset.index
      });
  },
  pay_before: function (e) {
    var t = this;
    if (typeof wx.requestSubscribeMessage === "function") {
      var tpl_msg_id = t.data.tpl_msg_id;
      return wx.requestSubscribeMessage({
        tmplIds: [tpl_msg_id],
        success: function (res) {
          console.log(res);
          t.data.form_id = tpl_msg_id
        },
        fail: function (res) {
          console.log(res);
        },
        complete: function (res) {
          t.pay();
        }
      })
    }
  },
  pay: function(e) {
    this.setData({
        show_payment: !0
    })
    
  },
  payPicker: function(t) {
        var e = t.currentTarget.dataset.index;
        this.setData({
            payment: e,
            show_payment: !1
        });
        this.pay_submit();
    },
    payClose: function() {
        this.setData({
            show_payment: !1
        });
    },
  pay_submit: function(e) {
    var t = this, n = {}, a = t.data.selected,  i = {};
    if (-1 == a) {
      
       return void getApp().core.showModal({
            title: "提示",
            content: "请选择充值套餐",
            showCancel: !1
        });
       
    }
    var p = t.data.list;
    i.pay_price = p[a].price, 
    i.duration = p[a].duration,
    i.package_id = p[a].id;

    i.payment = t.data.payment,
    i.pay_type = t.data.payment,
    //  i.formId = e.detail.formId,
      t.order_submit(i, "live");
  },


  input: function(e) {
      this.setData({
          money: e.detail.value
      });
  }
});